// 油猴插件
(function () {
  "use strict";
  // 移除空白
  const dom0 = document.querySelector("#main > div.container-fluid.mb-3.p-0");
  const dom1 = document.querySelector("#main > div.jsv.jsv-g1.mb-0");
  const dom2 = document.querySelector("#header > nav.new-nav-first.container-fluid > div > div.brand.col-30.col-md-20");
  dom0.remove();
  dom1.remove();
  dom2.remove();

  // 获取视频下载链接
  var u = document.querySelector("#video-play")?.dataset.src;
  if(!u) return 
  var auther = document.querySelector("#videoShowTabAbout > div > div:nth-child(1) > div:nth-child(1) > a").innerText;
  var date = document.querySelector("#videoShowTabAbout > div > div:nth-child(1) > div:nth-child(2)").innerText;
  var n = document.querySelector("#videoShowPage > div:nth-child(1) > div > h4").innerText;
  n = `${auther}_${n}`;

  var l =
    '"' +
    u +
    '" --workDir "F:\\.a\\sj\\20220909\\" --saveName "' +
    n +
    '" --enableDelAfterDone --disableDateInfo --noProxy --retryCount 100';
  console.log(u);
  console.log(l);
  l = "m3u8dl://" + Base64.encode(l);
  console.log(l);

  var a = document.createElement("a");
  a.setAttribute("href", l);
  a.innerText = '66666'
  a.addEventListener("click",function () {
    setTimeout(() => {
      window.opener = null
      window.close()
    }, 100);
  })

  // var input = document.createElement("input");
  // input.type = "button";
  // input.value = "m3u8视频下载";
  // a.appendChild(input);
  // a.click();
  document.body.prepend(a);
  // document.body.prepend(input)
  // document.querySelector("div.videoInfos.d-flex.text-normal.justify-content-between.align-items-center").appendChild(a);
})();
